﻿#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WaveEngine.Common.Math;
using WaveEngine.Components.Particles;
using WaveEngine.Framework;
using WaveEngine.Framework.Graphics; 
#endregion

namespace WaveEngine.Extensions.Behaviors
{
    public class ParticlesParentSizeBehavior : Behavior
    {
        [RequiredComponent]
        private ParticleSystem2D particleSystem = null;

        private Transform2D parentTransform;

        public Vector2 Scale { get; set; }

        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();
            this.parentTransform = this.Owner.Parent.FindComponent<Transform2D>();
        }

        protected override void Update(TimeSpan gameTime)
        {
            this.particleSystem.EmitterSize = new Vector2(
                this.parentTransform.Rectangle.Width * this.parentTransform.XScale * this.Scale.X,
                this.parentTransform.Rectangle.Height * this.parentTransform.YScale * this.Scale.Y);
        }
    }
}
